package com.zn.web.controler;

import com.zn.entity.AppVersion;
import com.zn.service.AppVersionService;
import com.zn.vo.Message;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author YinJiaWei
 * @version 2018/10/15 13:43
 */
@RestController
@RequestMapping("/appVersion")
public class AppVersionController {
    private static final Logger LOGGER = LoggerFactory.getLogger(AppVersionController.class);
    @Autowired
    private AppVersionService appVersionService;
    @RequestMapping(value = "/appVersionUpdate",method = RequestMethod.POST)
    public ResponseEntity<Message> appVersionUpdate(@RequestBody AppVersion appVersionDto) {
        try {
            if(appVersionDto.getAppType()==null || appVersionDto.getVersionNumber()==null){
                return ResponseEntity.ok(Message.ARGS_ERROR);
            }
            AppVersion appVersion=appVersionService.appVersionUpdate(appVersionDto);
            return ResponseEntity.ok(Message.successData(appVersion));
        }catch (Exception e){
            LOGGER.error("appVersionUpdate.....",e);
            return ResponseEntity.ok(Message.SYS_ERROR);
        }
    }
}
